<?php
class Dnsbl {
	private $blacklists;
	private $name;

	public function __construct($name) {
		$this->blacklists = array();
		$this->name = $name;
	}

	// Methods
	public function addBlacklist($name, $url) {
		$this->blacklists[$name] = new Blacklist($name, $url);
	}

	public function addReplyToBlacklist($name, $numeric, $description) {
		$this->blacklists[$name]->addReply($numeric, $description);
	}

	public function checkBLs($ip) {
		foreach ($this->blacklists as $blacklist) {
			if (($result = $blacklist->checkBL($ip)) !== false) {
				$rtn = trim($ip) . ' found in ' . trim($blacklist->getName()) . ' (' . trim($blacklist->getURL()) . ') under prefix ' . trim($result['numeric']) . ' (' . trim($result['description']) . ') - ' . trim($result['txt']) . "\n";
				
				return $rtn;
			}
		}

		return false;
	}

	// Accessors
	public function getName() { return $this->name; }
}
?>

